#!/bin/sh
# Copyright ©LanBright. All rights reserved.

### 使用说明 ###
# 1.指定备份 根目录名

# !!! 项目workspace名称
rootPathName="LanBKit_Example"

source_ipa=${1}
bundle=${2}
version=${3}
nowDay=$(date +"%Y_%m_%d")
channel=${4}
ipaName=${5}
dSYM=${6}

path="${rootPathName}/${bundle}/${version}/${nowDay}/${channel}"
ipa_path="$path/${ipaName}"
echo "path: $path"
echo "ipa_path: $ipa_path"

#创建空目录作为装载点
localSMB="/Volumes/UDE-Mac"
sudo mkdir "${localSMB}"
#游客登录
sudo mount -t smbfs //guest:@NAS/smb "${localSMB}"

full_path="$localSMB/iOS/${path}"
if [ ! -d $full_path  ];then
  sudo mkdir -p "${full_path}"
fi
echo "full_path: $full_path"

full_ipa_path="$full_path/${ipaName}"
echo "full_ipa_path: $full_ipa_path"
cp "${source_ipa}" "${full_ipa_path}"

full_dSYM_path="$full_path/${ipaName}.app.dSYM.zip"
echo "full_dSYM_path: $full_dSYM_path"
cp "${dSYM}" "${full_dSYM_path}"

#推出SMB服务
sudo umount "${localSMB}"
echo "上传完毕: $full_ipa_path"
